<html>
	<body>
		<?php
			require_once '../../../Helpers/DbHelper.php';
			require_once '../../../Controllers/StudentController.php';
			//
			$c = new StudentController();
			$i = $_REQUEST['id'];
			//
			if(isset($_POST['update']))
			{
				$a = array
				(
					'id' => $i, 
					'name' => $_POST['name'],
					'section' => $_POST['section'],
					'balance' => $_POST['balance'],
					'payment' => $_POST['payment']
				);
				$c->update($a);
				header("Location: ../view.php?id=$i");
			}
			else if(isset($_POST['cancel']))
			{
				header("Location: ../view.php?id=$i");
			}
			$s = mysql_fetch_object($c->read($i));
		?>
		<?php
			require_once '../Partials/Navigation.php';
			renderNavigation('../../');
		?>
		<br />
		Update Student
		<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
			ID: <input type="text" name="id" value="<?= $i ?>" /> <br />
			Name: <input type="text" name="name" value="<?= $s->Name; ?>" /> <br />
			Section: <input type="text" name="section" value="<?= $s->Section; ?>" /> <br />
			<input type="hidden" name="balance" value="<?= $s->Balance; ?>" />
			Payment: <input type="text" name="payment" value="0" /> <br />
			<input type="submit" name="cancel" value="Cancel" />
			<input type="submit" name="update" value="Update" />
		</form>
	</body>
</html>